<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>发布订阅模式</title>
</head>
<body>
	<script type="text/javascript">
		class SaleOffice {
			constructor () {
				this.msgList = [];
			}
			// 添加订阅
			listen (fn) {
				this.msgList.push(fn);
			}
			// 发布订阅
			trigger () {
				for (let i = 0, fn; fn = this.msgList[i++];) {
					fn.apply(this, arguments);
				}
			}
		}

		function client (price, squareMeter) {
			console.log('价格：' + price + '---' + '面积：' + squareMeter )
		}
		function client (price, squareMeter) {
			console.log('价格：' + price + '---' + '面积：' + squareMeter )
		}
		const test = new SaleOffice();
		test.listen(client);
		test.listen(client1);
		test.trigger(3000, 21)
		test.trigger(300, 22)
	</script>
</body>
</html>